package 笔试题.同花顺;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

/**
 * 字符串匹配，（）{}
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        System.out.println(charge(s));
    }

    public static boolean charge(String s) {
        if (s == null || s.length() < 1) return false;
        Deque<Character> stack = new LinkedList<>();
        char[] r = s.toCharArray();
        stack.push(r[0]);
        for (int j = 1; j < r.length; j++) {
            Character cur = r[j];
            Character peek = stack.peek();
            if ((cur == ')' && peek == '(') || (cur == '}' && peek == '{')) {
                stack.pop();
            } else {
                stack.push(r[j]);
            }
        }
        return stack.isEmpty();
    }
}
